Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #729 +/- ##
==========================================
+ Coverage 86.11% 86.16% +0.05%
==========================================
Files 69 69
Lines 2788 2791 +3
==========================================
+ Hits 2401 2405 +4
+ Misses 387 386 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve
labels_typesonScheduledTaskso non-string labels (int,float,bool,bytes) keep their types when a scheduled task is dispatched byTaskiqScheduler.on_ready().Root cause
AsyncKicker.schedule_by_cron(),schedule_by_interval(), andschedule_by_time()call_prepare_message(), which serializes label values into strings inmessage.labelsand records their types inmessage.labels_types.ScheduledTaskonly keptlabels=message.labelsand droppedlabels_types. WhenTaskiqScheduler.on_ready()later created a newAsyncKickerwithtask.labels, every value was re-serialized asLabelType.STR(turningFalseinto the truthy string"False",5into"5", andb"hi"into base64"aGk=").Solution
taskiq/scheduler/scheduled_task/task.py: add optionallabels_types: dict[str, int] | None = NonetoScheduledTaskso stored schedules remain JSON-serializable and backwards-compatible with schedules that omitlabels_types.taskiq/kicker.py: passlabels_types=message.labels_typesinschedule_by_cron,schedule_by_interval, andschedule_by_time.taskiq/scheduler/scheduler.py: restore typed labels viaparse_label()into a new dict before passing them toAsyncKickerinTaskiqScheduler.on_ready()(and copytask.labelswhenlabels_typesisNonesotask.labelsis not mutated).tests/scheduler/test_scheduler.py: add regression tests forschedule_by_cron,schedule_by_interval,schedule_by_time(including JSON round-trip) and forScheduledTaskinstances withoutlabels_types.Verification
uv run --no-sync pytest tests/test_kicker.py tests/test_task.py tests/test_utils.py tests/middlewares/ tests/brokers/ tests/scheduler/ -quv run --no-sync ruff check taskiq/kicker.py taskiq/scheduler/scheduler.py taskiq/scheduler/scheduled_task/task.py tests/scheduler/test_scheduler.pyuv run --no-sync mypy taskiq/kicker.py taskiq/scheduler/scheduler.py taskiq/scheduler/scheduled_task/task.py tests/scheduler/test_scheduler.py